#include <stdio.h>

int f(int a)
{
    // 每次调用会重新分配a, b
    int b = 0;
    // c只会在程序开始时分配一次并初始化
    // 后续调用会保留上一次的c值
    static int c = 3;
    b = b + 1;
    c = c + 1;
    printf("f(): b=%d, c=%d\n", b, c);
    printf("f(): &a=%p, &b = %p, &c=%p\n", &a, &b, &c);
    return (a + b + c);
}

int f2(void)
{
    int a = 0;
    int b = 0;
    f(a);
    return 0; 
}

int main(void)
{
    printf("Call f() for three times:\n");
    int ret = 0;
    ret = f(1);
    printf("ret = %d\n", ret);
    ret = f(1);
    printf("ret = %d\n", ret);
    ret = f(1);
    printf("ret = %d\n", ret);
    printf("Call f2():\n");
    f2();
    return 0;
}